var oldpwd ;
var uid;
$(function  () {

    //cookie数据赋值
    uid = $.cookie("lid");
    
    $.ajax({
        url: ipurl+'/user/getbyid',
        data: {
            ID:uid
        },
        type: "POST",
        //dataType: "json",
        success: function(data) {
            oldpwd = data.data.results[0].PASSWORD;
        }
    });

})
function changep(){
    var opwd = $("#opwd").val();
    var npwd = $("#npwd").val();
    if(opwd!=oldpwd){
      // layer.open({
      //     content: "原密码输入错误",
      //     end: function(index, layero){
      //         $("#opwd").val('');
      //         $("#npwd").val('');
      //     }
      // });
      layer.msg('原密码不正确');
    }else{
      $.ajax({
          url: ipurl+'/user/changepass',
          data: {
              ID: uid,
              pwd: npwd,
          },
          type: "POST",
          //dataType: "json",
          success: function(data) {
              layer.open({
                  content: "修改成功 ",
                  end: function(index, layero){
                      x_admin_close();
                      top.location.reload();
                  }
              });
          }
      });
    }
}